<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
        <title>绩效考核管理系统-登录</title>
        <link rel="stylesheet" type='text/css' href='/public/css/common/common.css' />
	</head>

	<body class="body">
		<br><br>
		<div class="title">
			欢迎使用绩效考核管理系统
		</div>
		<br><br>
		<div class="login">
			<h2>登录系统</h2>
            <br>
			<span id="error" class="error">{{ error }}</span>
			<form id="form" method="post" action="/login">
				<br>
				<span>账号：</span><input type="text" id="user_nick" name="user_nick" value="" placeholder="请输入账号">
				<span class="error">*</span>
				<br><br>
				<span>密码：</span><input type="password" id="user_pwd" name="user_pwd" value="" placeholder="请输入密码">
				<span class="error">*</span>
				<br><br>
				<input type="button" id="submit_btn" value="登录">
			</form>
		</div>

		<script src="/public/js/common/jquery-1.12.4.min.js"></script>
		<script>
            $(document).keydown(function(event) {
				if(event.keyCode == 13) {
					submitForm()
				}
			});

			$("#submit_btn").click(function() {
				submitForm()
			})

            function  submitForm() {
                if (checkForm()) {
                    $("#error").html("正在提交...");
                    $("#form").submit();
                }
            }

            function checkForm() {
                console.log($("#user_nick").val())
                $("#error").html("");
                if($("#user_nick").val().trim() == '') {
					$("#error").html("请输入账号");
                    return false;
				}
				if($("#user_pwd").val().trim() == '') {
					$("#error").html("请输入密码");
                    return false;
				}
				return true;
            }

			$("#user_nick").blur(function() {
				checkForm()
			})

			$("#user_pwd").blur(function() {
				checkForm()
			})
		</script>
	</body>

</html>